package cn.westv.scps.service.sys.dict.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.westv.scps.dao.BaseDao;
import cn.westv.scps.domain.SysDictItem;
import cn.westv.scps.service.sys.dict.ISysDictItemService;
import cn.westv.scps.utils.Page;

@Service
@Transactional
public class SysDictItemServiceImpl implements ISysDictItemService {
	@Resource(name = "baseDao")
	private BaseDao baseDao;

	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public List<SysDictItem> find(String hql, Class<SysDictItem> entityClass, Object[] params) {
		return baseDao.find(hql, entityClass, params);
	}

	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public SysDictItem get(Class<SysDictItem> entityClass, Serializable id) {
		return baseDao.get(entityClass, id);
	}

	@Transactional(propagation = Propagation.NOT_SUPPORTED)
	public Page<SysDictItem> findPage(String hql, Page<SysDictItem> page, Class<SysDictItem> entityClass,
			Object[] params) {
		return baseDao.findPage(hql, page, entityClass, params);
	}

	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void saveOrUpdate(SysDictItem entity) {
		baseDao.saveOrUpdate(entity);
	}

	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void saveOrUpdateAll(Collection<SysDictItem> entitys) {
		baseDao.saveOrUpdateAll(entitys);
	}

	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void deleteById(Class<SysDictItem> entityClass, Serializable id) {
		baseDao.deleteById(entityClass, id);
	}

	@Override
	@Transactional(readOnly = false, isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
	public void delete(Class<SysDictItem> entityClass, Serializable[] ids) {
		for (Serializable id : ids) {
			deleteById(entityClass, id);
		}

	}

}
